<template>
  <view class="page">
    <uni-nav-bar
      title="个人资料"
      left-icon="left"
      showMenuButtonWidth
      statusBar
      backgroundColor="#fff"
      :border="false"
      @clickLeft="$tools.back"
    />
    <view class="avatar-container">
      <view class="avatar">
        <image
          class="avatar-image"
          src="/static/images/base/default_avatar.png"
        />
      </view>
    </view>
    <view class="form-contanier">
      <uni-forms
        ref="form"
        :model="formData"
      >
        <uni-forms-item
          label="昵称"
          prop="nickname"
        >
          <uni-easyinput
            type="text"
            v-model="formData.nickname"
            placeholder="请输入昵称"
            :inputBorder="false"
          />
        </uni-forms-item>
        <uni-forms-item
          label="手机"
          prop="mobile"
        >
          <uni-easyinput
            type="text"
            v-model="formData.mobile"
            :inputBorder="false"
            :clearable="false"
            disabled
          />
          <text class="text-primary text-sm">修改</text>
        </uni-forms-item>
        <uni-forms-item
          label="性别"
          prop="gender"
        >
          <uni-data-checkbox
            v-model="formData.gender"
            :localdata="genders"
            selectedColor="#E60012"
          />
        </uni-forms-item>
        <uni-forms-item
          label="生日"
          prop="birthday"
        >
          <uni-datetime-picker
            type="date"
            return-type="timestamp"
            v-model="formData.birthday"
            placeholder="仅支持修改一次"
            :border="false"
            :clear-icon="false"
          />
        </uni-forms-item>
      </uni-forms>
    </view>
    <view class="tips">
      根据未成年人保护相关法律法规的要求，我们不主动处理14周岁以下成年人的个人信息。如果您为14周岁以下的用户，请勿填写您的个人资料。
    </view>
    <button class="save-btn">保存</button>
    <view class="logout">退出登录</view>
  </view>
</template>
<script>
export default {
  name: "UserInfo",
  data() {
    return {
      formData: {
        nickname: "",
        mobile: "147******10",
        gender: "",
        birthday: ""
      },
      // 单选数据源
      genders: [
        {
          text: "男",
          value: 0
        },
        {
          text: "女",
          value: 1
        }
      ]
    }
  }
}
</script>
<style lang="scss" scoped>
.avatar-container {
  width: 100%;
  background-color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 70rpx 0;
  margin-bottom: $uni-spacing-row-xl;
}

.avatar {
  position: relative;
  width: 200rpx;
  height: 200rpx;
  border-radius: 100%;
  &::after {
    content: "";
    position: absolute;
    bottom: 0;
    right: 10rpx;
    width: 50rpx;
    height: 50rpx;
    background-image: url("/pages/customer-center/static/userinfo/photo.png");
    background-size: 100% 100%;
    background-repeat: no-repeat;
  }
  &-image {
    width: 100%;
    height: 100%;
    border-radius: 100%;
  }
}

.form-contanier {
  background-color: #fff;
  padding: 0 $uni-spacing-row-base;
}

.tips {
  padding: $uni-spacing-row-lg;
  color: $uni-text-color-grey;
  font-size: $uni-font-size-sm;
  line-height: 1.5;
}

.save-btn {
  background-color: $uni-color-primary;
  color: #fff;
  font-size: $uni-font-size-base;
  border-radius: $uni-border-radius-base;
  height: 90rpx;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: $uni-spacing-row-xxl $uni-spacing-row-lg $uni-spacing-row-lg;
}

.logout {
  position: fixed;
  bottom: calc($uni-spacing-row-xl + var(--window-bottom));
  left: 0;
  right: 0;
  color: $uni-text-color-grey;
  font-size: $uni-font-size-base;
  text-align: center;
}

::v-deep {
  .uni-forms-item {
    margin-bottom: 0;
    padding: 16rpx 0;
  }

  .uni-forms-item__label {
    color: $uni-text-color-grey;
  }

  .uni-easyinput__placeholder-class {
    color: $uni-text-color-grey;
    font-size: $uni-font-size-base;
  }

  .icon-calendar {
    display: none;
  }

  .uni-forms-item__content {
    display: flex;
    align-items: center;
  }

  .uni-input-input:disabled {
    color: $uni-text-color;
    background-color: #fff;
  }

  .is-disabled {
    color: $uni-text-color !important;
    background-color: #fff !important;
  }
}
</style>
